package com.demo.controller;


import com.demo.dto.Result;
import com.demo.entity.AnswerLike;
import com.demo.entity.UserCollect;
import com.demo.service.AnswerLikeService;
import com.demo.service.UserCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Zeng
 * @since 2022-03-23
 */
@RestController
@RequestMapping("/answer-op")
@Api(tags = "回答相关操作（点赞、收藏等）")
public class AnswerOperationController {
    @Resource
    AnswerLikeService answerLikeService;

    @Resource
    UserCollectService userCollectService;

    @PostMapping("/like/{answer_id}")
    @ApiOperation("问题点赞-取消")
    Result<AnswerLike> like(@PathVariable("answer_id") Integer answerId) {
        return answerLikeService.like(answerId);
    }

    @PostMapping("/collect/{answer_id}")
    @ApiOperation("问题收藏-取消")
    Result<UserCollect> collect(@PathVariable("answer_id") Integer answerId) {
        return userCollectService.collect(answerId);
    }
}

